Ext.define('Admin.view.process.model.ProcessModelGrid', {
    extend: Ext.grid.Panel,
    xtype: 'processmodel-grid',
    id: 'processmodel-grid',
    title: '流程模型',

    iconCls: 'x-fa fa-arrow-circle-o-up',
    //cls: 'user-grid', 
    controller: 'processmodel',
    viewModel: {
        type: 'processmodel'
    },
    bind: '{processmodelStore}',

    //sm:new Ext.grid.CheckboxSelectionModel(),
    columns: [{
            header: 'id',
            dataIndex: 'id',
            width: 100,
            sortable: true,
            hidden: true
        },
        {
            header: '模型名称',
            dataIndex: 'name',
            width: 100,
            sortable: true
        },
        {
            header: '模型key',
            dataIndex: 'key',
            width: 120,
            sortable: true
        },
        {
            header: 'category',
            dataIndex: 'category',
            width: 120,
            sortable: true,
            hidden: true
        },
        {
            header: '创建时间',
            dataIndex: 'createTime',
            width: 145,
            sortable: true,
            renderer: Ext.util.Format.dateRenderer('Y/m/d H:i:s')
        },
        {
            header: '最后修改时间',
            dataIndex: 'lastUpdateTime',
            width: 145,
            sortable: true,
            renderer: Ext.util.Format.dateRenderer('Y/m/d H:i:s')
        },
        {
            header: '版本',
            dataIndex: 'version',
            width: 60,
            sortable: true
        },
        {
            header: '元数据',
            dataIndex: 'metaInfo',
            width: 180,
            sortable: true
        },
        {
            header: 'deploymentId',
            dataIndex: 'deploymentId',
            width: 60,
            sortable: true,
            hidden: true
        },
        {
            header: 'tenantId',
            dataIndex: 'tenantId',
            width: 60,
            sortable: true,
            hidden: true
        },
        {
            header: 'taskId',
            dataIndex: 'taskId',
            width: 60,
            sortable: true,
            hidden: true
        },
        {
            header: 'editorSource',
            dataIndex: 'editorSource',
            width: 60,
            sortable: true,
            hidden: true
        },
        {
            header: 'editorSourceExtra',
            dataIndex: 'editorSourceExtra',
            width: 60,
            sortable: true,
            hidden: true
        }, {
            header: '在线编辑',
            dataIndex: 'id',
            width: 80,
            sortable: true,
            renderer: function(value, metaData, record, rowIdx, colIdx, store, view) {
                return '<a target="_blank" href="modeler.html?modelId=' + record.get('id') + '">编辑</a>';
            }
        }, {
            header: '导出',
            dataIndex: 'id',
            width: 100,
            sortable: true,
            renderer: function(value, metaData, record, rowIdx, colIdx, store, view) {
                return '<a href="model/export/' + record.get('id') + '/bpmn" target="_blank">BPMN</a>' +
                    '|&nbsp;<a href="model/export/' + record.get('id') + '/json" target="_blank">JSON</a>';
                /*
                +'|&nbsp;<a href="model/export/${model.id}/json" target="_blank">SVG</a>'; //showSvgTip()
                */
            }
        }, {
            xtype: 'actioncolumn',
            items: [{
                xtype: 'button',
                iconCls: 'x-fa fa-trash-o',
                tooltip: '删除',
                handler: 'onClickProcessModelGridDeleteButton'
            }, {
                xtype: 'button',
                iconCls: 'x-fa fa-cog',
                tooltip: '部署',
                handler: 'onClickProcessModelGridDeployButton'
            }],
            cls: 'content-column',
            width: 80,
            dataIndex: 'bool',
            text: '操作'
        }
    ],
    dockedItems: [{
        xtype: 'pagingtoolbar',
        dock: 'bottom',
        bind: '{processmodelStore}',
        displayInfo: true,
        items: [
            '-',
            {
                text: '添加',
                iconCls: 'x-fa fa-plus',
                listeners: {
                    click: 'onClickProcessModelGridAddButton'
                }
            }
        ]
    }]
});